<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Login Form
 *
 * @author Matej Kollar
 */
class Application_Form_Login extends Zend_Form {

    public function __construct($options = null) {
        parent::__construct($options);

        // Set the method for the display form to POST
        $this->setMethod('post');

        // Add an email element
        $this->addElement('text', 'email', array(
            'label' => 'Email:',
            'required' => true,
            'filters' => array('StringTrim'),
            'validators' => array('EmailAddress'),
            'attribs' => array(
                'size' => 30
            )
        ));

        // Add a password element
        $this->addElement('password', 'password', array(
            'label' => 'Password:',
            'required' => true,
            'validators' => array(
                new Zend_Validate_Alnum(),
                new Zend_Validate_StringLength(array(
                    'min' => 8,
                    'max' => 15
                )))
        ));

        // Add the Log In button
        $this->addElement('submit', 'logIn', array(
            'ignore' => true,
            'label' => 'Log In'
        ));

        // And finally add some CSRF (Cross-Site request forgery) protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));
    }

}
